﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DAL;
using System.Data;
using System.Data.SqlClient;

namespace BUS
{
    class NhanVien_BUS : SqlDataProvider
    {
        SqlDataProvider db = new SqlDataProvider();
        private static NhanVien_DAO _nhanvienDAO = new NhanVien_DAO();
        public DataTable Nhan_Vien_Login(string loginname, string pass)
        {
            SqlDataProvider db = new SqlDataProvider();
            SqlParameter[] p = new SqlParameter[2];
            p[0] = new SqlParameter("@LoginName", loginname);
            p[1] = new SqlParameter("@Password", pass);
            return db.myTable_sp("sp_Sel_Where_NhanVien", p);
        }
        public DataTable Thong_Tin_Nhan_Vien(string loginname)
        {
            SqlDataProvider db = new SqlDataProvider();
            SqlParameter[] p = new SqlParameter[1];
            p[0] = new SqlParameter("@TenDangNhap", loginname);
            return db.myTable_sp("sp_Sell_ThongTin_NhanVien", p);
        }
        public int PhanQuyen_NguoiDung(string Quyen)
        {
            SqlCommand cmd = new SqlCommand();
            cmd = new System.Data.SqlClient.SqlCommand("sp_KiemTraQuyen_NhanVien", GetConnection());
            cmd.CommandType = System.Data.CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@TenDangNhap", Quyen);
            int maquyen = (int)cmd.ExecuteScalar();
            return maquyen;
        }
        public DataTable allNhanVien()
        {
            return db.myTable_sp("sp_sell_allNV");
        }
        public bool Del(string tenDn)
        {
            SqlParameter p0 = new SqlParameter("@TenDangNhap", tenDn);
            return db.exe_sp("sp_del_NV", p0);
        }
        public static bool Customer_Insert_Up(VO.NhanVien_OBJ obj)
        {
            return _nhanvienDAO.Customer_Insert_Up(obj);
        }
    }
}
